<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <title>管理系统</title>
    <meta content="webkit" name="renderer">
    <link href="favicon.ico" rel="icon" type="image/x-icon"/>
    <link href="src/style/login.css" rel="stylesheet">
    <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
    <meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"
          name="viewport">
    <link href="start/layui/css/layui.css" media="all" rel="stylesheet">
    <style>
        html,
        body {
            height: 100%;
            background-color: #f2f2f2;
        }
    </style>
</head>

<body>
<div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">
    <div class="layadmin-user-login-main">
        <div class="layadmin-user-login-box layadmin-user-login-header">
            <h2>erp管理系统</h2>
        </div>
        <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-username"
                       for="LAY-user-login-username"></label>
                <input autocomplete="off" class="layui-input" id="LAY-user-login-username" name="username"
                       placeholder="用户名" type="text">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-password"
                       for="LAY-user-login-password"></label>
                <input autocomplete="off" class="layui-input" id="LAY-user-login-password" name="pwd" placeholder="密码"
                       type="password">
            </div>

            <div class="layui-form-item" style="margin-top: 80px;">
                <button class="layui-btn layui-btn-fluid" lay-filter="LAY-user-login-submit" lay-submit>登 陆</button>
            </div>
        </div>
    </div>

    <div class="layui-trans layadmin-user-login-footer">
        <p>© All Rights Reserved</p>
    </div>

</div>
<script src="start/layui/layui.js"></script>
<script>
    layui.use(['form'], function () {
        var $ = layui.$
            , form = layui.form
        form.render();
        //提交
        form.on('submit(LAY-user-login-submit)', function (obj) {
            //请求登入接口
            $.ajax({
                url: '/v2/login'
                , type: 'post'
                , data: obj.field
                , success: function (res) {
                    //登入成功的提示与跳转
                    if (res.code == 200) {
                        layer.msg('登入成功', {
                            offset: '15px'
                            , icon: 1
                            , time: 100
                        }, function () {
                            location.href = '/index.html#'
                        });
                    } else {
                        layer.msg('登录失败', {
                            offset: '15px'
                            , icon: 5
                            , time: 10000
                        })
                    }
                }
            });

        });

    });
</script>
</body>

</html>
